<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
        <script type="text/javascript" src="lib/html5shiv.js"></script>
        <script type="text/javascript" src="lib/respond.min.js"></script>
        <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />

    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
        <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
    <title>帮助中心</title>
</head>

<body>
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 公告管理 <span
            class="c-gray en">&gt;</span> 帮助中心 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
            href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div>
                    <select name="" class="input-text" id="usrecompStatus" style="width:15%;">
                            <option value="">-请选择-</option>
                            <option value="1">常见问题</option>
                            <option value="2">订单问题</option>
                            <option value="3">推广问题</option>
                            <option value="4">其他问题</option>
                            <option value="5">关于我们</option>
                        </select>
                    	<button type="submit" class="btn btn-success" id="search_btn" name="" data-type="reload"><i class="Hui-iconfont">&#xe665;</i>搜索</button>    
                </div>

        <div class="">  
            <table class="layui-hide" id="noticelList" lay-filter="noticelList"></table>
        </div>
    </div>
    <input type="" name="details_id" id="details_id" value="" style="display:none;" />
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="./../static/js/common.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="./../lib/layui/layui.js"></script>
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/html" id="operation">
        <a  title="编辑" lay-event="edit" class=""><i class="Hui-iconfont">&#xe6df;</i></a>
        <a  title="删除" lay-event="del" class=""><i class="Hui-iconfont">&#xe6e2;</i></a>
</script>
<script type="text/html" id="toolbar">
    <div class="cl"><a class="btn btn-primary radius" onclick="product_add()" href="javascript:;"><i
        class="Hui-iconfont">&#xe600;</i> 添加帮助</a></span> </div>
  </script>
    <script type="text/javascript">
        layui.use('table',function(){
            var table = layui.table;
          var insTable = table.render({
                elem:'#noticelList',
                toolbar: '#toolbar',
                defaultToolbar: [],
                cellMinWidth: 80,
                url: admin_url + '/kvmHelpCenter/helpCenterList',
                // id为重置表格，进行搜索
                id: 'reload',
                request: {
                    pageName: 'page',
                    limitName: 'size'
                },
                // 传输模式
                // contentType: 'application/json',
                paresData: function (res) {
                    return {
                        'data': res.data
                    }
                },
                response: {
                    statusCode: 200
                },
                // // 传入数据
                where: {
                    tokenUserId: userId,
                    token: token
                },
                // 回调
                done: function (res, curr, count) {
                },
                method: 'post',
                page:"true",
                cols:[[
                { checkbox: true, align: 'center' },
                { field: 'id', title: 'ID', align: 'center',width:80  },
                { field: 'title', title: '标题', align: 'center'  },
                { field: 'type', title: '所属类目', align: 'center',templet:function(obj){
                    if(obj.type == 1){
                        return '<span>常见问题</span>'
                    }else if(obj.type == 2){
                        return '<span>订单问题</span>'
                    }else if(obj.type == 3){
                        return '<span>推广问题</span>'
                    }else if(obj.type == 4){
                        return '<span>其他问题</span>'
                    }else if(obj.type == 5){
                        return '<span>关于我们</span>'
                    }
                }  },
                { field: 'sort', title: '排序', align: 'center'  },
                { field: 'createTime', title: '创建时间', align: 'center'  },
                { toolbar: '#operation', title: '操作', align: 'center'  }
                ]]
            })
                 // 搜索功能 需要在标签上加载data-type = reload
            $('#search_btn').on('click', function () {
                var usrecompStatus = $("#usrecompStatus option:selected").val();
                insTable.reload({
                    where: {
                        "token": token,
                        "tokenUserId": userId,
                        "type": usrecompStatus,
                    }, page: {
                        curr: 1
                    }
                });
            });
             // 监听行操作栏事件。。可直接传值..
             table.on('tool(noticelList)', function (obj) {
                var data = obj.data;
                var id = data.id;
                if (obj.event === 'edit') {
                        var index = layer.open({
                            type:2,
                            title:'编辑',
                            id:id,
                            content:'./edit-help.html'
                        })
                        layer.full(index);
                        $("#details_id").val(id)
                }else if(obj.event === 'del'){
                    layer.confirm('是否删除?',{title:'删除'},function(){
                          // 调用删除接口
                          $.ajax({
                            type: "post",
                            xhrFields: { withCredentials: true },
                            url: admin_url + '/kvmHelpCenter/delHelpCenter',
                            data: { tokenUserId: userId, token: token,id:id },
                            success: function (data) {
                                if (data.code == 200) {
                                    layer.msg('删除成功', {
                                        time: 1000,
                                        end: function () {
                                            $(".layui-laypage-btn").click();
                                        }
                                    })
                                } else {
                                    layer.msg(data.msg)
                                }
                            }, error: function () {
                              
                            }
                        })
                    })
                }
            })
        })
        // 打开添加活动页面
    function product_add(){
        var index = layer.open({
		type: 2,
		title: '添加帮助',
		content: './add-help.html'
	});
	layer.full(index);
    }
    </script>
</body>

</html>